﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Imaginecup.util;
using Microsoft.Xna.Framework;
using Imaginecup.util.collision;
using Microsoft.Xna.Framework.Graphics;
using imaginecup.util;
using Imaginecup.sprite;
using Microsoft.Xna.Framework.Input;
using Imaginecup.sprite.changeSourceSize;
using Imaginecup.gameState.btnStateUtil;

namespace Imaginecup.gameState.option
{
    public class EnabletBtnInfo:ISourceInfoClass
    {
        private BtnInfo m_BtnInfo;
        private EntityInfo m_BtnEntityInfo;
        private EntityInfo m_SourceInfo;

        public EnabletBtnInfo()
        {
        }
        public void SetBtnInfo(BtnInfo info)
        {
            m_BtnEntityInfo = info.GetEntityInfo();
            m_BtnInfo = info;
            m_SourceInfo = new EntityInfo(new Vector2(0, 0), m_BtnEntityInfo.mSize);
        }

        public BtnInfo GetBtnInfo()
        {
            return m_BtnInfo;
        }

        public EntityInfo GetEntityInfo()
        {
            return m_BtnInfo.GetEntityInfo();
        }
        
        public void Update()
        {            

            IMouseInputHandler input = MouseInputHandler.GetInputHandler();


            if (!m_BtnInfo.GetEnable())
            {
                m_SourceInfo = new EntityInfo(new Vector2(0, 0), m_BtnEntityInfo.mSize);
                return;
            }
            if (Collision.CollisionByPoint(m_BtnEntityInfo, input.Position) && input.MouseState.LeftButton == ButtonState.Pressed)
            {
                m_SourceInfo = new EntityInfo(new Vector2(m_BtnEntityInfo.mSize.X, 0), m_BtnEntityInfo.mSize);
                return;
            }

            m_SourceInfo = new EntityInfo(new Vector2(0, 0), m_BtnEntityInfo.mSize);
        }

        public EntityInfo GetSourceInfo()
        {
            return m_SourceInfo;
        }


        public void Release()
        {
            m_BtnInfo = null;
        }
    }
}
